package zcj.stu.dao;

import com.mongodb.client.result.DeleteResult;
import com.mongodb.client.result.UpdateResult;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Repository;
import zcj.stu.Entity.Account;

import javax.annotation.Resource;
import java.util.List;

@Repository
public class AccountDao {
    @Resource
    private MongoTemplate mongoTemplate;

    public Account ckUAndP(Query query) {
         return mongoTemplate.findOne(query,Account.class);
    }

    public Account save(Account account) {
        return mongoTemplate.insert(account);
    }

        public DeleteResult del(Query query) {
        return mongoTemplate.remove(query,Account.class);
    }
    public UpdateResult edit(Query query, Update update){
       return mongoTemplate.updateFirst(query,update,Account.class);
    }
}
